package com.qcxk.yuqian.system.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Component;

import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;

@Component
public class MailUtil {
    @Autowired
    private JavaMailSender javaMailSender;

    public void testSend(String to, String html) throws MessagingException {
        MimeMessage mimeMessage = javaMailSender.createMimeMessage();
        MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage);
        messageHelper.setSubject("代运单已发货-本尊快递");
        messageHelper.setFrom("bannexpress@bannerking.com.my");
        messageHelper.setTo(to);
        messageHelper.setText(html, true);
        javaMailSender.send(messageHelper.getMimeMessage());
    }
}
